<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard_model extends OC_Model {

	public function get_last_articles()
	{
		$this->db->limit(5);
		$this->db->order_by('a_id', 'desc');
		return $this->db->get('articles')->result();
	}

	public function get_last_events()
	{
		$this->db->limit(5);
		$this->db->order_by('e_id', 'desc');
		return $this->db->get('events')->result();
	}

	public function get_last_categories()
	{
		$this->db->limit(5);
		$this->db->select("
			a.c_caption_en,
		    count(c.n_id)items
		", FALSE);

		$this->db->from('category a');
		$this->db->join('articles c', 'a.c_id = c.n_c_id', 'left');
		$this->db->group_by('a.c_id');
		$this->db->order_by('a.c_id', 'desc');
		return $this->db->get()->result();
	}

	public function get_last_products()
	{
		$this->db->limit(5);
		$this->db->select("
			a.p_name,c.cp_name
		", FALSE);

		$this->db->from('products a');
		$this->db->join('category_product c', 'a.cp_id = c.cp_id', 'left');
		$this->db->order_by('a.p_id', 'desc');
		return $this->db->get()->result();
	}


	public function get_hot_products()
	{
		return TRUE;
	}

	public function get_last_messages()
	{
		return TRUE;
	}

	public function get_last_invoice()
	{
		return TRUE;
	}

}

/* End of file dashboard_model.php */